package com.pingxx.boot.demo.kafka;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Slf4j
@Component
public class UserProducer {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void send(Object message) {
        kafkaTemplate.send(UUID.randomUUID().toString(), JSON.toJSONString(message));
    }

}
